import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/**
 * 设计思路: 实际路由和菜单并不是强关联, 路由嵌套结构和菜单嵌套结构不必一致, 于是有以下实现原则
 * 1. 定义异步组件
 * 2. 定义静态路由
 * 3. 定义自定义菜单
 * 4. 更新状态器, 刷新页面菜单结构
 */

// 默认不在菜单内显示
export const staticRouters = [
  { path: '/login', name: 'Login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/close', name: 'Close', component: () => import('@/views/close/index'), hidden: true },
  { path: '/404', name: '404', component: () => import('@/views/404'), hidden: true }
]

// 异步路由, 默认都Layout下子路由的目录
export const dynamicRouters = [
  { name: 'kdMenus', path: 'menu/sysMenu', props: true, component: () => import('@/views/menu/sysMenus') },
  { name: 'servicerMenus', path: 'menu/servicerMenus', props: true, component: () => import('@/views/menu/servicerMenus') },
  { name: 'businessMenus', path: 'menu/businessMenus', props: true, component: () => import('@/views/menu/businessMenus') },
  { name: 'pubDomainMenu', path: 'menu/pubDomainMenu', props: true, component: () => import('@/views/menu/pubDomainMenu') },
  { name: 'pubDomainBusinessMenu', path: 'menu/pubDomainBusinessMenu', props: true, component: () => import('@/views/menu/pubDomainBusinessMenu') },
  { name: 'userManage', path: 'user/userManage', props: true, component: () => import('@/views/user/userManage') },
  { name: 'roleManage', path: 'user/roleManage', props: true, component: () => import('@/views/user/roleManage') },
  { name: 'wxappCodeTemplate', path: 'wxapp/codeTemplate', component: () => import('@/views/wxapp/template/index') },
  { name: 'updateManage', path: 'wxapp/update_manage', props: true, component: () => import('@/views/wxapp/updateManage/index') },
  {
    name: 'releaseUpdate', path: 'wxapp/release_update/:classifyTplId',
    props: true, component: () => import('@/views/wxapp/updateManage/release')
  },
  { name: 'wxappVersion', path: 'wxapp/version', props: true, component: () => import('@/views/wxapp/version/index') },
  { name: 'wxappDetail', path: 'wxapp/detail/:wxappRelationId', props: true, component: () => import('@/views/wxapp/manage/WxappDetail') },
  { name: 'wxappQrcodeManage', path: 'wxapp/qrcode/:appId', props: true, component: () => import('@/views/wxapp/manage/QrcodeManage') },
  { name: 'wxappRelation', path: 'wxapp/biz', props: true, component: () => import('@/views/wxapp/manage/BizWxapp') },
  { name: 'kdWxapp', path: 'wxapp/kd', props: true, component: () => import('@/views/wxapp/manage/KdWxapp') },
  { name: 'spWxapp', path: 'wxapp/sp', props: true, component: () => import('@/views/wxapp/manage/SpWxapp') },

  { name: 'templateMsg', path: 'msg/template', props: true, component: () => import('@/views/msg/TemplateMsg') },
  { name: 'kdPermission', path: 'perm/kd', props: true, component: () => import('@/views/perm/KdPermission') },
  { name: 'spPermission', path: 'perm/sp', props: true, component: () => import('@/views/perm/SpPermission') },
  { name: 'bizPermission', path: 'perm/biz', props: true, component: () => import('@/views/perm/BizPermission') },
  { name: 'pubDomainManagePermission', path: 'perm/pdm', props: true, component: () => import('@/views/perm/PubDomainManagePermission') },
  { name: 'pubDomainBusinessPermission', path: 'perm/pdb', props: true, component: () => import('@/views/perm/PubDomainBusinessPermission') },
  { name: 'kdFeature', path: 'feature/kd', props: true, component: () => import('@/views/feature/KdFeature') },
  { name: 'spFeature', path: 'feature/sp', props: true, component: () => import('@/views/feature/SpFeature') },
  { name: 'bizFeature', path: 'feature/biz', props: true, component: () => import('@/views/feature/BizFeature') },
  { name: 'PubWxaTplFeatureEntrance', path: 'wxapp/entrance/pubDomainFeature', props: true, component: () => import('@/views/wxapp/entrance/PubDomainFeature') },
  { name: 'pubDomainManageFeature', path: 'feature/pubManag', props: true, component: () => import('@/views/feature/PubDomainManageFeature') },
  { name: 'pubDomainBusinessFeature', path: 'feature/puBusiness', props: true, component: () => import('@/views/feature/PubDomainBusinessFeature') },
  { name: 'bizTplMsgMange', path: 'msg/biz', props: true, component: () => import('@/views/msg/WxaBusinessList') },
  { name: 'wxaTemplateMgr', path: 'msg/wxa/tpl/:appId', props: true, component: () => import('@/views/msg/WxaTemplateMgr') },
  { name: 'businesslist', path: 'businessManage/businesslist', props: true, component: () => import('@/views/business/businessList') },
  { name: 'addBusiness', path: 'businessManage/businesslist/add', props: true, component: () => import('@/views/business/addBusiness') },
  { name: 'editBusiness', path: 'businessManage/businesslist/edit/:id', props: true, component: () => import('@/views/business/editBusiness') },

  { name: 'WxaTplFeatureEntrance', path: 'wxapp/entrance/feature', props: true, component: () => import('@/views/wxapp/entrance/Feature') },
  { name: 'WxaTplServiceEntrance', path: 'wxapp/entrance/service', props: true, component: () => import('@/views/wxapp/entrance/Service') },

  { name: 'addTemplateMsg', path: 'msg/template/add', props: true, component: () => import('@/views/msg/addTemplate') },
  { name: 'editTemplateMsg', path: 'msg/template/edit/:id', props: true, component: () => import('@/views/msg/editTemplate') },
  { name: 'templateMsgConfig', path: 'msg/templateConfig', props: true, component: () => import('@/views/msg/TemplateMsgConfig') },
  { name: 'templateMsgSend', path: 'msg/templateMsgSend/:id', props: true, component: () => import('@/views/msg/TemplateMsgSend') },
  { name: 'templateMsgEditSms', path: 'msg/templateMsgEditSms', props: true, component: () => import('@/views/msg/TemplateMsgEditSms') },
  { name: 'templateMsgSmsRecord', path: 'msg/templateMsgSmsRecord', props: true, component: () => import('@/views/msg/TemplateMsgSmsRecord') },
  { name: 'orderMessage', path: 'msg/orderMessage', props: true, component: () => import('@/views/msg/orderMessage') },

  // 知识库-
  { name: 'ContentManagement', path: 'knowledge/ContentManagement', props: true, component: () => import('@/views/knowledge/ContentManagement') },
  { name: 'Article', path: 'knowledge/ArticleManagement', props: true, component: () => import('@/views/knowledge/ArticleManagement') },
  { name: 'NewArticle', path: 'knowledge/NewArticle', props: true, component: () => import('@/views/knowledge/NewArticle') },
  { name: 'Draft', path: 'knowledge/Draft', props: true, component: () => import('@/views/knowledge/Draft') },
  { name: 'ArticleSee', path: 'knowledge/ArticleSee', props: true, component: () => import('@/views/knowledge/ArticleSee') },
  { name: 'AuthorManagement', path: 'knowledge/AuthorManagement', props: true, component: () => import('@/views/knowledge/AuthorManagement') },
  { name: 'MaterialManagement', path: 'knowledge/MaterialManagement', props: true, component: () => import('@/views/knowledge/MaterialManagement') },
  { name: 'NewMaterial', path: 'knowledge/NewMaterial', props: true, component: () => import('@/views/knowledge/NewMaterial') },
  { name: 'ArticleClassManagement', path: 'knowledge/ArticleClassManagement', props: true, component: () => import('@/views/knowledge/ArticleClassManagement') },
  { name: 'MaterialClassManagement', path: 'knowledge/MaterialClassManagement', props: true, component: () => import('@/views/knowledge/MaterialClassManagement') },
  { name: 'LabelManagement', path: 'knowledge/LabelManagement', props: true, component: () => import('@/views/knowledge/LabelManagement') },
  { name: 'PcDecorate', path: 'knowledge/PcDecorate', props: true, component: () => import('@/views/knowledge/PcDecorate') },
  { name: 'AppDecorate', path: 'knowledge/AppDecorate', props: true, component: () => import('@/views/knowledge/AppDecorate') },
  // { name: 'NavigationEditing', path: 'knowledge/NavigationEditing', props: true, component: () => import('@/views/knowledge/NavigationEditing') },
  // { name: 'CarouselMapEditing', path: 'knowledge/CarouselMapEditing', props: true, component: () => import('@/views/knowledge/CarouselMapEditing') },
  // { name: 'ListEditing', path: 'knowledge/ListEditing', props: true, component: () => import('@/views/knowledge/ListEditing') },
  // 流量配置
  { name: 'orgBaseConf', path: 'flowConf/orgBaseConf', props: true, component: () => import('@/views/flowConf/orgBaseConf') },
  { name: 'mercPackageManage', path: 'flowConf/mercPackageManage', props: true, component: () => import('@/views/flowConf/mercPackageManage') },
  { name: 'flowWarning', path: 'flowConf/flowWarning', props: true, component: () => import('@/views/flowConf/flowWarning') },
  { name: 'purchaseAudit', path: 'flowConf/purchaseAudit', props: true, component: () => import('@/views/flowConf/purchaseAudit') },
  // 插件配置
  { name: 'plugConfigIndex', path: 'plugConfig/plugConfigIndex', props: true, component: () => import('@/views/plugConfig/plugConfigIndex') },
  // 商户通用配置
  { name: 'mercComConfig', path: 'mercComConfig', props: true, component: () => import('@/views/mercComConfig/index') }
]
const router = new Router({
  routes: staticRouters,
  scrollBehavior: () => ({ y: 0 })
})

export default router
